<style type="text/css">
/* reset */
html{}
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,input,button,textarea,p,blockquote,th,td{margin:0;padding:0;box-sizing: border-box;}
body{font:14px/1 SimHei,Tahoma,Helvetica,Arial,"\5b8b\4f53",sans-serif;}
img{border:none;}
em,strong{font-style:normal;font-weight:normal;}
li{list-style:none;}
table {border-collapse:collapse;border-spacing:0;}
h1{font-size:14px;font-weight: bold;line-height: 15px;}
h2{font-size:14px;}
h3{font-size:14px;}
h4, h5, h6{font-size:100%;}

q:before,q:after{content:'';}/* 消除q前后的内容 */
button,input,select,textarea{font-size:100%;}/* 使得表单元素在 ie 下能继承字体大小 */
input,button,textarea,select,optgroup,option{font-family:inherit;font-size:inherit;font-style:inherit;font-weight:inherit;}
address,cite,dfn,em,var{font-style:normal;} /* 将斜体扶正 */

/* link */
a{text-decoration:none;}
a:hover{color:black;text-decoration:underline;}
body{ background: #C8C8C8; }
.fll{ float: left; }
.flr{ float: right; }
.mar-lf-5{ margin:0 5px; }
.cl-ov{ clear: both; overflow: hidden; width: 100%; }
.gird-3{ width: 15%; }
.gird-7{ width: 85%; }
.content{ max-width: 350px; padding: 5px; background: white; margin: 0 auto;}
.content .con-title { padding: 5px 0; border-bottom: 2px solid black;}
.content .con-title .con-title-info{font-size: 12px;}
.content  .con-info p{ overflow: hidden; margin:0; line-height: 16px; }
.content  .con-info .infon{ padding:5px; overflow: hidden; clear: both; border:1px dotted #E7E7E7; }
.content  .con-info .infon:nth-child(2){ border-top: 1px solid black; border-bottom: medium none; padding: 0 5px; text-align: center; line-height: 18px; }
.content  .con-info .infon .infon-left span:nth-child(1){ width: 55%; }
.content  .con-info .infon .infon-left span:nth-child(2){ width: 45%; }
.content  .con-info .infon .infon-right { border-left: 1px dotted #E7E7E7; }
.content  .con-info .infon .infon-right span{ width: 100%; }
.content  .con-info .infon span{display: block; float: left; text-align: left;}
.content .con-info2{ border:1px solid #666666; margin-top:2px; }
.content .con-info2 .con-info2-title{ overflow: hidden; border-bottom: 1px solid black; }

.content .con-info2 .con-info2-title li{ float: left; line-height: 18px; }
.content .con-info2 .con-info2-title li{ width: 10%; text-align: center; border-right: 1px solid black; }
.content .con-info2 .con-info2-title li:nth-child(1){ width: 80%; text-align: left; padding-left: 10px; }
.content .con-info2 .con-info2-title li:last-child{ border:none; }
.content .con-info2   .con-info2-text { border-top:5px solid #999999; border-bottom: 5px solid #999; }
.content .con-info2   .con-info2-text >div{ padding:0 5px; border-bottom:1px dotted #BBBBBB; }
.content .con-info2   .con-info2-text .text1 li{ float: left; text-align: center; line-height: 18px; }
.content .con-info2   .con-info2-text .text1 li:nth-child(1){ width: 80%; text-align: left;}
.content .con-info2   .con-info2-text .text1 li  { width: 20%; }
.content .con-info2   .con-info2-text .text2{border:solid; line-height: 18px; }
.content .table.table-bordered.table-hover th,.content .table.table-bordered.table-hover td{padding: 5px; font-size: 13px; border: 1px solid;}
</style>
<style media="print">
.pageNext{
page-break-after:always;
}
</style>
<div class="printlist">
    <?php 
    $printlist = $this->printlist;
    foreach ($printlist as $print){
    ?>
    <div class="content">
        <div class="con-title cl-ov">
            <h1 class="fll mar-lf-5"><?php if($print['orderlog']['site'] == 'elmontyouthsoccer.com'){echo 'elmontyouthsoccer';}else{echo $print['orderlog']['site'];};?></h1>
            <div class="con-title-info flr mar-lf-5">
                <p><span><?php echo date('Y-m-d', time());?></span><span>&nbsp;No:<?php echo $print['orderlog']['order_id'];?></span><span>&nbsp;Sum：$<?php echo $print['orderlog']['total_amount']?></span></p>
                <p><span><?php echo $print['buyer']['name']?></span></p>
            </div>
        </div>
        <div class="con-info cl-ov">
            <div class="infon">
                <p>
                    <span>Consignee:<?php echo $print['buyer']['contact_name'];?></span>
                    <span style="float: right;">Tel:<?php echo $print['buyer']['phone'];?></span>
                </p>
                <p><span style="width: 100%;">Add:<?php echo $print['buyer']['address'].' '.$print['buyer']['state'].' '.$print['buyer']['city'].' '.$print['buyer']['post_code'].' '.$print['buyer']['country'];?></span></p>
            </div>
            <div class="infon">
                <div class="fll gird-7 infon-left">
                    <span>Tracking No：</span>
                    <span style="float: right;">Shippment:<?php if($print['orderlog']['ship_company']=='Shipping Tool of Ebay'){echo 'ePacket';}else if($print['orderlog']['ship_company']=='Standard Shipping'){echo 'Standard';}?></span>
                </div>
                <div class="fll gird-3 infon-right">
                    <span>Weight：</span>
                </div>
            </div>
        </div>
        <div class="con-info2 cl-ov">
            <table class="table table-bordered table-hover">
                <thead><tr><th>Item's Name</th><th>Size</th></tr></thead>
                <tbody>
                    <?php
                    $k = 0;
                    foreach($print['stocklog'] as $v){
                    	$k+=1;
                	    $info = json_decode($v['info']);
                	    $in = '';
                	    foreach ($info as $vv){
                	    	$in = $in . $vv[0].'/'.$vv[1].',';
                    	}
                    	if(!empty($v['product_name'])){
                    ?>
                    <tr class="item">
                        <td>
                            <?php echo $v['product_name'];?>
                            <?php 
                            if(!empty($v['print_msg'])){
                            	$str = $v['print_msg'];
                            	$str = str_replace('Size:', '',$str);
                            	$str = str_replace(',Amount:', '/',$str);
                            	$str = str_replace('SelectOrginalNum:,', '',$str);
                            	$str = str_replace(' Want ', '',$str);
                            	$str = str_replace('Want ', '',$str);
                            	$str = str_replace('Want', '',$str);
                            	$str = str_replace('<br/>', '',$str);
                            	$str = str_replace('BadgePatch: no', '',$str);
                            	$str = str_replace('BadgePatch:', '',$str);
                            	$str = str_replace(', Price:$5', '',$str);
                            	$str = str_replace(' Price:$5', '',$str);
                            	$str = str_replace('Price:$5', '',$str);
                            	$str = str_replace('$5', '',$str);
                            	$str = str_replace('|', '',$str);
                                echo '【'.trim($str).'】';
                            }
                            ?>
                        </td>
                        <td><?php echo $in;?></td>
                    </tr>
                    <?php if($k%3 == 2){ ?>
                    <!-- <tr class="pageNext"></tr> -->
                    <?php }
                    	}
                    }
                    ?>
                    <tr class="item end-tag"></tr>
                </tbody>
            </table>
        </div>
    </div>
    <div class="pageNext"></div>
    <?php }?>
</div>
<script type="text/javascript">
$(document).ready(function(){
	$(".table").each(function(i){
		var len = $(this).children("tbody").children(".item").length;
		$(this).children("tbody").children(".item").each(function(j){
			if(j == 0){
				k0 = 0;
			}else{
				var k0 = j-1;
			}
			var pj = $(".table:eq("+i+")").children("tbody").children(".item:eq("+j+")").position();
			var pk0 = $(".table:eq("+i+")").children("tbody").children(".item:eq("+k0+")").position();
			var mj = Math.floor(pj.top/360);
			var mk0 = Math.floor(pk0.top/360);
			console.log(pj)
			if(pj.top%360 === 0 && i == 0){
				$(this).before("<tr class='pageNext'></tr>");
			}else{
				if(mk0<mj && len > 2){
					$(".table:eq("+i+")").children("tbody").children(".item:eq("+k0+")").before("<tr class='pageNext'></tr>");
				}
			}
		});
	});
});
</script>